#include<iostream>
#include<string>
#include<vector>
using namespace std;
int lengthOfLongestSubstring(string s)
{
    int arr[128] = { 0 };
    size_t mSizej = 0;
    size_t max = 0;
    size_t i = 0;
    size_t j = 0;
    while (j < s.size())
    {
        i = j;
        while (i < s.size())
        {
            if (arr[s[i]] != 1)
            {
                arr[s[i]]++;
            }
            else
            {
                int tmp = 0;
                for (int k = 0; k < 128; ++k)
                    tmp += arr[k];
                if (tmp > max)
                {
                    max = tmp;
                    //mSizej=j;
                }
                for (int k = 0; k < 128; ++k)
                    arr[k] = 0;
                break;
            }
            ++i;
        }
        ++j;
    }
    return max;
}
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) 
{
    vector<int> nums3;
    size_t i = 0;
    size_t j = 0;
    size_t index = nums1.size() + nums2.size();
    nums3.reserve(index);
    //nums3.push_back(1);
    while (i < nums1.size() && j < nums2.size())
    {
        if (nums1[i] < nums2[j])
            nums3.push_back(nums1[i++]);
        else
            nums3.push_back(nums2[j++]);
    }
    while (i < nums1.size())
        nums3.push_back(nums1[i++]);
    while (j < nums2.size())
        nums3.push_back(nums2[j++]);
    if (index % 2 == 0)
        return ((nums3[index / 2] + nums3[index / 2 - 1])) / 2.0;
    return nums3[index / 2];
}
void test()
{
	//int arr[128] = { 0 };
	//string s1(" ");
    //cout << lengthOfLongestSubstring(s1) << endl;
	//arr[s1[0]] += 1;
	//for (int i = 0; i < 128; ++i)
		//cout << i << ":" << arr[i] << " ";
    //vector<int> num1;
    //vector<int> num2;
    //num1.push_back(1);
    //num1.push_back(2);
    //num2.push_back(3);
    //num2.push_back(4);
    //cout<<findMedianSortedArrays(num1, num2) << endl;
}
bool isPalindrome(string s)
{
    string rs = s;
    reverse(rs.begin(), rs.end());
    return rs == s;
}
string longestPalindrome(string s)
{
    size_t j = 0, i = 0;
    size_t n = 0, pos = 0;
    for (i = 0; i < s.size(); ++i)
    {
        for (j = 1; j <= s.size() - i; ++j)
        {
            if (isPalindrome(s.substr(i, j)))
            {
                if (j > n)
                {
                    n = j;
                    pos = i;
                }
            }
        }
    }
    return s.substr(pos, n);
}
void test1()
{
    //string s1("hello");
    //string s2("hello");
    //cout << (s1 == s2) << endl;
    string s1("a");
    //cout << isPalindrome(s1) << endl;
    cout << longestPalindrome(s1) << endl;
}
int maxArea(vector<int>& height)
{
    int i = 0;
    int max = 0;
    for (i = 0; i < height.size(); ++i)
    {
        for (int j = i + 1; j < height.size(); ++j)
        {
            int tmp = (j - i) * (height[j] > height[i] ? height[i] : height[j]);
            if (max < tmp)
            {
                max = tmp;
            }
        }
    }
    return max;
}
void test2()
{
    vector<int> arr;
    arr.push_back(1);
    arr.push_back(8);
    arr.push_back(6);
    arr.push_back(2);
    arr.push_back(5);
    arr.push_back(4);
    arr.push_back(8);
    arr.push_back(3);
    arr.push_back(7);
    int a = 10;
    //int& b = a;
    cout << maxArea(arr) << endl;
    //[1, 8, 6, 2, 5, 4, 8, 3, 7]

}
int main()
{
	test2();
	return 0;
}

